#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct sensor {
	unsigned int indice;
	unsigned int intervalo;
	unsigned int tiempo;
};

/*void imprimir_vector(const vector<sensor> &s) {
	cout << "[";
	for(vector<sensor>::const_iterator it = s.begin(); it != s.end(); ++it) {
		cout << "(" << it->indice << "," << it->intervalo << "," << it->tiempo << ")" << " ";
	}
	cout << "] ";
}*/

bool comparar_sensores(const sensor &s1, const sensor &s2) {
	return s1.tiempo > s2.tiempo || ((s1.tiempo == s2.tiempo) && s1.indice > s2.indice);
}

unsigned int ej2(unsigned int k, vector<sensor> &sensores) {
	make_heap(sensores.begin(), sensores.end(), comparar_sensores);
	
	for(unsigned int i = 1; i < k; i++) {
		sensor s = sensores.front();
		
		pop_heap(sensores.begin(), sensores.end(), comparar_sensores);
		sensores.pop_back();
		
		s.tiempo += s.intervalo;
		
		sensores.push_back(s);
		push_heap(sensores.begin(), sensores.end(), comparar_sensores);
	}
	
	return sensores.front().indice;
}

int main() {
	while ( cin.good() ) {
		char car;
		
		cin >> car;
		
		if (car == '#')
			break;
		
		unsigned int n = car - '0', k;
		cin >> k;
		vector<sensor> sensores;
		
		for(unsigned int i = 1; i <= n; i++) {
			sensor s;
			unsigned int intervalo;
			cin >> intervalo;
			
			s.indice = i;
			s.intervalo = intervalo;
			s.tiempo = 0;
			
			sensores.push_back(s);
		 }
		 
		 cout << ej2(k, sensores) << endl;
	 }
}
